package cn.sunxinao.pm.text;

import cn.sunxinao.pm.models.AbstractUser;

public class User extends AbstractUser {
    private static final String SPLIT_STR = "\\|";

    public User() {
    }

    public static User ofString(String str) {
        String[] split = str.split(SPLIT_STR);
        if (split.length < 2) throw new IllegalArgumentException("Wrong user info string");
        User user = new User();
        user.username = split[0];
        user.password = split[1];
        return user;
    }

    public String writeToString() {
        return username + '|' + password;
    }

}
